module.exports = app => {
    const { STRING, INTEGER } = app.Sequelize;

    const Book = app.model.define('book', {
        book_id: STRING,
        name: STRING,
        price: STRING,
        category: STRING,
        createDate: STRING,
        press: STRING,
        author: STRING,
        info: STRING,
        cover: STRING,
        clazz_id: INTEGER
    })

    Book.associate = () => {
        app.model.Book.belongsTo(app.model.Clazz, {  //设置外键
            foreignKey: 'clazz_id',
            targetKey: 'id'
        })
    }

    return Book;

}